package com.tjetc.controller;

import com.tjetc.common.JsonResult;
import com.tjetc.entity.BedInfo;
import com.tjetc.entity.ElderInfo;
import com.tjetc.service.BedInfoService;
import com.tjetc.service.ElderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("bedInfo")
public class BedInfoController {
    @Autowired
    private BedInfoService bedInfoService;

    @RequestMapping("detail/{bedId}")
    public JsonResult detail(@PathVariable("bedId") Long id) {
        return bedInfoService.findById(id);
    }
    @RequestMapping("page")
    public JsonResult page(@RequestParam(value = "wardId", required = false,defaultValue = "") Integer wardId,
                           @RequestParam(value = "status", required = false,defaultValue = "") Integer status,
                           @RequestParam(value = "pageNo",required = false,defaultValue = "1") Integer pageNo,
                           @RequestParam(value = "pageSize",required = false,defaultValue = "2") Integer pageSize) {
        return bedInfoService.findPage(wardId,status,pageNo,pageSize);
    }
    @RequestMapping("delete/{bedId}")
    public JsonResult delete(@PathVariable("bedId") Long id) {
        return bedInfoService.deleteById(id);
    }
    //接收参数格式是json
    @RequestMapping("save")
    public JsonResult save(@RequestBody BedInfo bedInfo){
        return bedInfoService.save(bedInfo);
    }
    //接收参数格式是json
    @RequestMapping("bedcount")
    public JsonResult bedcount(){
        return bedInfoService.selectBedNumber();
    }
}
